package com.woniuxy.config;

import com.alibaba.druid.pool.DruidDataSource;
import io.seata.rm.datasource.DataSourceProxy;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @Author: 马宇航
 * @Todo: TODO
 * @DateTime: 25/08/08/星期五 15:35
 * @Component: 成都蜗牛学苑
 **/
@Configuration
public class SeataConfig {
//    @Primary
//    @Bean
//    @ConfigurationProperties(prefix = "spring.datasource")
//    public DruidDataSource druidDataSource(){
//        return new DruidDataSource();
//    }
    @Bean
    @Primary
    public DataSource dataSource(DataSourceProperties properties) {
        DruidDataSource druidDataSource = properties.initializeDataSourceBuilder().type(DruidDataSource.class).build();
        return new DataSourceProxy(druidDataSource);
    }
}
